<%@page import="java.util.ArrayList"%>
<%@page import="cn.sendto.model.UserInfoModel"%>
<%@page import="java.util.List"%>
<%@page import="cn.sendto.service.UserInfoService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" errorPage="../err.jsp"%>
	<jsp:include page="../lock.jsp"></jsp:include>
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询用户</title>
<style>
.txt20 {
	font-size: 20px;
}

.input {
	width: 60px;
	height: 25px;
}
</style>
</head>
<style >
.txt24{
	font-size:24px;
}
</style>

<body>
<%
	request.setCharacterEncoding("UTF-8");
	if (request.getAttribute("userinfo") != null) {
		out.print(request.getAttribute("userinfo"));
	}
	UserInfoService uis = new UserInfoService();
	String select = request.getParameter("select");
	String type = request.getParameter("type");
	
	%>
   <div class="txt20">当前位置-->查询用户</div>

	<form action="userlist.jsp" method="post">
	<span>搜索关键字：</span>&nbsp;
		<input type="text" name="select" placeholder="请输入要查询的用户名、姓名、电话">
		身份： <select name="type">
			<option value="0" selected="selected">全部</option>
			<option value="1">超级管理员</option>
			<option value="2">一般管理员</option>
		</select> 
		&nbsp;&nbsp;<input type="submit" name="查询" value="查询" value="查询" class="input">
	</form>
	<%
	UserInfoModel uim = (UserInfoModel) session.getAttribute("loginUser");
	
			List<UserInfoModel> list = new ArrayList<UserInfoModel>();
			 if (select == null  && type == null ) {
				list = uis.allUser();
			} 
			if (type != null && (select == null  || select.equals(""))) {
				list = uis.selecttype(type);
				out.print("查询到"+list.size()+"条信息");
			}else if(select != null && type != null ){
				list = uis.select(select, type);
				out.print("查询到"+list.size()+"条信息");
			}
			if(list.size() > 0){
	%>
	<table width="95%" class="txt12" style="background-color: #00BBEE"
		cellspacing="1" cellpadding="0">
		<tr style="background-color: #EEEEEE; height: 30px">
			<th>序号</th>
			<th>用户名</th>
			<th>姓名</th>
			<th>电话</th>
			<th>用户类别</th>
		
		</tr>
		<%
			for (int i = 0; i < list.size(); i++) {
		%>
		<tr style="background-color: white; height: 25px;">
			<td align="center"><%=i + 1%></td>
			<td align="center"><%=list.get(i).getUserName()%></td>
			<td align="center"><%=list.get(i).getName()%></td>
			<td align="center"><%=list.get(i).getUsertel()%></td>
			<td align="center"><%=list.get(i).getType() == 1 ? "超级管理员" : "一般管理员"%></td>
			<td align="center">
			<%
			}
			}
		
 %>
			</td>
		</tr>
	</table>


</body>
</html>